package com.ye.auth.controller;

import com.ye.auth.dto.LoginBody;
import com.ye.auth.dto.RegisterBody;
import com.ye.auth.service.SysLoginService;
import com.ye.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: baby
 * @Date: 2023/10/10 00:16
 * @Description:
 */
@Api(value = "系统入口")
@RestController
public class TokenController {

    @Autowired
    private SysLoginService loginService;

    @ApiOperation("注册用户")
    @PostMapping("/register")
    public R<?> register(RegisterBody registerBody){
        return loginService.register(registerBody);
    }

    @ApiOperation("登录")
    @PostMapping("/login")
    public R<?> login(LoginBody loginBody){
        return loginService.login(loginBody);
    }
    @ApiOperation("退出登录")
    @GetMapping("/logout")
    public R<?> logout(){
        return loginService.logout();
    }

    @ApiOperation("获取用户详情")
    @GetMapping("/userInfo")
    public R<?> getUserInfo(){
        return loginService.getUserInfo();
    }

}
